home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
sdoc210
/
sdsample.sub
< prev
next >
Wrap
Text File
|
1993-02-03
|
2KB
|
50 lines
DefInt A-Z
'' This module deals with discovering how much of a form
'' gets lost with the border.
'' **** NB Essential for all VB programmers ****
'' Written by Peter Fox. 3 Feb 1993
'' 2 Tees Close, Witham, Essex CM8 1LG,England
'' Domestic tel: 0376 517206
'' Intnl tel: +44 376 517206
'' (Compuserve ID: 100116,1031)
'' Make the best use of them you can.
Declare Function GetSystemMetrics Lib "User" (ByVal nIndex As Integer) As Integer
'' API call works with Win 3.0 provided nIndex <= 35(decimal)
'' Constants declared with the style SM_...
Const SM_CXSCREEN = 0
Const SM_CYSCREEN = 1
Const SM_CYCAPTION = 4 ' pixels height of a caption bar (also menu bar)
Const SM_CXBORDER = 5 ' pixels width of a frame border (technically non-sizeable!)
Const SM_CYBORDER = 6 ' pixels height of a frame border (technically non-sizeable!)
Const SM_CYMENU = 15
Const SM_CXFULLSCREEN = 16
Const SM_CYFULLSCREEN = 17
Const SM_CXFRAME = 32
Const SM_CYFRAME = 33
Function lostframeheightintwips% (withmenu%)
'' Return the height (in twips) that is lost because the FORM.HEIGHT property
'' includes the title and borders
'' If WITHMENU% is true then we have to inclue a (single) menu bar in the
'' value to be lost.
captionht = GetSystemMetrics(SM_CYCAPTION) ' system dimensions in pixels
fixborderHt = GetSystemMetrics(SM_CYBORDER)
sizborderHt = GetSystemMetrics(SM_CYFRAME)
stppy = screen.TwipsPerPixelY ' conversion factor for this screen
If withmenu% Then m = 2 Else m = 1 ' 2 title heights if we have a menu bar
lostheightinpix = (m * (captionht - fixborderHt)) + (2 * sizborderHt)
lostframeheightintwips = lostheightinpix * stppy
End Function
Function LostFramewidthintwips% ()
'' Return the width (in twips) that is lost because the FORM.WIDTH
'' property includes the borders
sizborderWd = GetSystemMetrics(SM_CXFRAME) ' pixel width of frame
stppx = screen.TwipsPerPixelX ' conversion factor
lostwidthinpix = 2 * sizborderWd
LostFramewidthintwips = lostwidthinpix * stppx
End Function